package com.kongwg.exer;

public class instanceTest {
	public static void main(String[] args) {
		instanceTest test =new instanceTest();
		test.method(new Person());
		System.out.println("*******************");
		test.method(new Student());
		System.out.println("*******************");
		test.method(new Graduate());
	
	}
	public void method(Person e){
		System.out.println(e.getInfo());
		if(e instanceof Graduate){
			System.out.println("a graduate student \n a student \n a person");
		}else if(e instanceof Student){
			System.out.println("a student\n a person");
		}else if(e instanceof Person){
			System.out.println("a person");
			
		}
	}
}


class Person{
	protected String name = "person";
	protected int age = 50;
	public String getInfo(){
		return "Name:"+name+"\n"+"age:"+age;
	}
}
class Student extends Person{
	protected String school = "pku";
	public String getInfo(){
		return "Name:"+name+"\n"+"age:"+age+"\nschool:"+school;
	}
}
class Graduate extends Student{
	public String major="IT";
	public String getInfo(){
		return "Name:"+name+"\n"+"age:"
	+age+"\nschool:"+school+"\nmajor:"+major;
	}
}
